#ifndef USERMANAGER_H
#define USERMANAGER_H

#include <QObject>
#include <QList>
#include "Networking/user.h"
#include "Change/usermessage.h"

class Session;

class UserManager : public QObject
{
Q_OBJECT

public:
	UserManager(Session *newParent);

	User getLocalUser();
	void setLocalUser(User newDetails);
	User getUserFromId(int id) {return userList.at(id);}
        void deleteUser(int id);
	void processUserMessage(UserMessage newUser);	//updates or adds a user given a user message
	void userServerHandshake(QList<UserMessage> newUsers);	//adds a list of users from the server. Used only when user connects to a new session
	QList<User> getUserList() {return userList;}
	void saveSession(QString filename);
        void loadSession(QString filename);
        QColor decodeColor(QString col);    //Get colour out of qreal R, G, B, A string of numbers

signals:
	void userChanged(int id, QString name, QColor colour, bool enabled);

public slots:
	void preferencesChanged();	//called when the user changes preferences

private:
	Session *session;

	int localUserId;
	QList<User> userList;
};

#endif //USERMANAGER_H
